
module.exports = {
  countPositionResultConservative () {
    // 实在不行就只做all4天和reason两种
    if (!this.marketInfo) {
      return
    }
    if (
      this.marketFlagInfo.ifMarket15mAllGood4Days ||
      this.marketFlagInfo.ifMarket15mAllBad4Days
    ) {
      this.positionConfig = 0.5
      return
    }
    // if (this.marketInfo.canOpenList.length > 20) {
    //   this.positionConfig = 1
    //   return
    // }
    if (
      (
        this.marketFlagInfo.ifMarket15mAllGood3Days ||
        this.marketFlagInfo.ifMarket15mAllBad3Days
      ) &&
      (
        this.marketFlagInfo.ifMarket1hAllBad ||
        this.marketFlagInfo.ifMarket1hAllGood
      )
    ) {
      this.positionConfig = 0.5
      return
    }
    // 混沌期间
    // if (
    //   (this.marketInfo.attack15m && this.marketInfo.kdj15mGood) ||
    //   (this.marketInfo.crash15m && this.marketInfo.kdj15mBad) ||
    //   (this.marketInfo.kdj15mBad && this.marketInfo.macd15mBad && this.marketInfo.ema15mBad) ||
    //   (this.marketInfo.kdj15mGood && this.marketInfo.macd15mGood && this.marketInfo.ema15mGood)
    // ) {
    //   if (
    //     (
    //       // 可以开的少，也很恶心的
    //       this.marketInfo.canOpenList.length > 10 &&
    //       !this.marketMachine.ifMarketModelLike('[[[0,1],1,1],[-1,0,0],[-1,-1,0],[-1,-1,-1]]') &&
    //       !this.marketMachine.ifMarketModelLike('[[[0,-1],-1,-1],[1,0,0],[1,1,0],[1,1,1]]')
    //     ) ||
    //     (
    //       this.marketFlagInfo.ifMarket1hAllBad ||
    //       this.marketFlagInfo.ifMarket1hAllGood
    //     )
    //   ) {
    //     this.positionConfig = 1
    //     return
    //   }
    // }
    // if (
    //   this.marketFlagInfo.ifMarket15mAllGood ||
    //   this.marketFlagInfo.ifMarket15mAllBad
    // ) {
    //   this.positionConfig = 0.5
    //   return
    // }
    // TODO 控制仓位真的是太对了，这个阶段简直就是反复割
    if (Math.abs(this.marketInfo.marketPriceChangePercent) < 1.2) {
      this.positionConfig = 0.15
      return
    }
    if (this.marketMachine.ifMarketModelLike([[0, 0, 0], [0, 'any', 0], ['any', 0, 0], ['any', 'any', 'any']])) {
      this.positionConfig = 0.15
      return
    }
    if (this.marketMachine.ifMarketModelLike([[0, 0, 0], [0, 0, 0], [0, 'any', 0], ['any', 'any', 'any']])) {
      this.positionConfig = 0.15
      return
    }
    if (this.marketMachine.ifMarketModelLike([[0, 0, 0], ['any', 0, 0], [0, 0, 0], ['any', 'any', 'any']])) {
      this.positionConfig = 0.15
      return
    }
    if (this.marketMachine.ifMarketModelLike([[0, 0, 0], [0, 0, 0], ['any', 0, 0], ['any', 'any', 'any']])) {
      this.positionConfig = 0.15
      return
    }
    if (this.marketMachine.ifMarketModelLike([[0, 0, 0], ['any', 0, 0], ['any', 0, 0], ['any', 'any', 'any']])) {
      this.positionConfig = 0.2
      return
    }
    if (this.marketMachine.ifMarketModelLike([['any', 0, 0], ['any', 0, 0], ['any', 0, 0], ['any', 'any', 'any']])) {
      if (!(this.marketFlagInfo.ifMarket15mMacdEmaAllGood || this.marketFlagInfo.ifMarket15mMacdEmaAllBad)) {
        this.positionConfig = 0.2
        return
      }
    }
    this.positionConfig = 0.33
  },
  countPositionResult () {
    if (!this.marketInfo) {
      return
    }
    if (
      (
        this.marketFlagInfo.ifMarket15mAllGood4Days ||
        this.marketFlagInfo.ifMarket15mAllBad4Days
      )
    ) {
      this.positionConfig = 1
      return
    }
    if (
      (
        this.marketFlagInfo.ifMarket15mAllGood3Days ||
        this.marketFlagInfo.ifMarket15mAllBad3Days
      ) &&
      (
        this.marketFlagInfo.ifMarket1hAllBad ||
        this.marketFlagInfo.ifMarket1hAllGood
      )
    ) {
      this.positionConfig = 1
      return
    }
    // 混沌期间
    if (
      (this.marketInfo.attack15m && this.marketInfo.kdj15mGood) ||
      (this.marketInfo.crash15m && this.marketInfo.kdj15mBad) ||
      (this.marketInfo.kdj15mBad && this.marketInfo.macd15mBad && this.marketInfo.ema15mBad) ||
      (this.marketInfo.kdj15mGood && this.marketInfo.macd15mGood && this.marketInfo.ema15mGood)
    ) {
      if (
        (
          // 可以开的少，也很恶心的
          this.marketInfo.canOpenList.length > 10 &&
          !this.marketMachine.ifMarketModelLike('[[[0,1],1,1],[-1,0,0],[-1,-1,0],[-1,-1,-1]]') &&
          !this.marketMachine.ifMarketModelLike('[[[0,-1],-1,-1],[1,0,0],[1,1,0],[1,1,1]]')
        ) ||
        (
          this.marketFlagInfo.ifMarket1hAllBad ||
          this.marketFlagInfo.ifMarket1hAllGood
        )
      ) {
        this.positionConfig = 1
        return
      }
    }
    if (
      (this.marketInfo.kdj4hGood && this.marketInfo.ema4hGood && this.marketInfo.macd4hGood) &&
      (this.marketInfo.kdj1dGood || this.marketInfo.ema1dGood || this.marketInfo.macd1dGood) &&
      !(this.marketInfo.ema1hBad || this.marketInfo.macd1hBad)
    ) {
      this.positionConfig = 1
      return
    }
    if (
      this.marketFlagInfo.ifMarket4hAllBad &&
      this.marketFlagInfo.ifMarket1dHasBad &&
      !(this.marketInfo.ema1hGood || this.marketInfo.macd1hGood)
    ) {
      this.positionConfig = 1
      return
    }
    if (
      (this.marketInfo.kdj1dGood && this.marketInfo.kdj4hGood && this.marketInfo.kdj1hGood) ||
      (this.marketInfo.kdj1dBad && this.marketInfo.kdj4hBad && this.marketInfo.kdj1hBad)
    ) {
      this.positionConfig = 1
      return
    }
    // 不是1的都打折
    // TODO 控制仓位真的是太对了，这个阶段简直就是反复割
    if (Math.abs(this.marketInfo.marketPriceChangePercent) < 1.2) {
      this.positionConfig = 0.2
      return
    }
    if (
      // 开始涨不动了
      (this.marketInfo.kdj1dGood && this.marketInfo.macd1dGood) &&
      (this.marketInfo.macd4hGood && this.marketInfo.ema4hGood) &&
      this.marketInfo.macd1hBad
    ) {
      this.positionConfig = 0.5
      return
    }
    if (
      // 开始跌不动了
      (this.marketInfo.kdj1dBad && this.marketInfo.macd1dBad) &&
      (this.marketInfo.macd4hBad && this.marketInfo.ema4hBad) &&
      this.marketInfo.macd1hGood
    ) {
      this.positionConfig = 0.5
      return
    }
    if (
      (this.marketInfo.kdj1dBad && this.marketInfo.kdj4hGood) ||
      (this.marketInfo.kdj1dGood && this.marketInfo.kdj4hBad)
    ) {
      this.positionConfig = 0.5
      return
    }
    if (
      (
        (this.marketInfo.macd4hGood && this.marketInfo.ema4hGood) &&
        (this.marketInfo.macd1hGood || this.marketInfo.ema1hGood) &&
        (this.marketInfo.kdj4hGood || this.marketInfo.kdj1hGood)
      ) ||
      (
        (this.marketInfo.macd4hBad && this.marketInfo.ema4hBad) &&
        (this.marketInfo.macd1hBad || this.marketInfo.ema1hBad) &&
        (this.marketInfo.kdj4hBad || this.marketInfo.kdj1hBad)
      )
    ) {
      this.positionConfig = 0.75
      return
    }
    if (this.marketMachine.ifMarketModelLike([[[0, 1], 1, 1], [1, 0, 1], [[0, 1], 1, 1], ['any', 'any', 'any']])) {
      this.positionConfig = 0.75
      return
    }
    // if (
    //   this.marketMachine.ifMarket1dModelLike([0, 0, 1]) &&
    //   this.marketMachine.ifMarket4hModelLike([0, 1, [0, 1]]) &&
    //   this.marketMachine.ifMarket1hModelLike(['any', 0, [0, 1]])
    // ) {
    //   this.positionConfig = 0.35
    //   return
    // }
    // 垃圾时间，这个之后就做做allbad和allgood好了
    if ((this.marketInfo.ema4hGood && !this.marketInfo.macd4hGood)) {
      if (this.marketInfo.ema1hBad) {
        this.positionConfig = 0.35
        return
      }
    }
    if ((this.marketInfo.ema4hBad && !this.marketInfo.macd4hBad)) {
      if (this.marketInfo.ema1hGood) {
        this.positionConfig = 0.35
        return
      }
    }
    if (
      (this.marketInfo.kdj4hGood && this.marketInfo.likeDuo) ||
      (this.marketInfo.kdj4hBad && this.marketInfo.likeKong)
    ) {
      this.positionConfig = 0.75
      return
    }
    // if (this.marketMachine.ifMarket4hModelLike([0, 0, 0])) {
    //   if (
    //     this.marketMachine.ifMarket1hModelLike(['any', 0, 0]) &&
    //     this.marketMachine.ifMarket15mModelLike(['any', 'any', 0])
    //   ) {
    //     this.positionConfig = 0.35
    //     return
    //   }
    //   if (
    //     this.marketMachine.ifMarket1hModelLike(['any', 'any', 0]) &&
    //     this.marketMachine.ifMarket15mModelLike(['any', 0, 0])
    //   ) {
    //     this.positionConfig = 0.35
    //     return
    //   }
    // }
    if (
      // 死憋着的行情，他也不是要做正向，而是会偶尔出现不停涨的东西，其他的其实也不涨
      this.marketMachine.ifMarket1dModelLike([0, [-1, 0], 0]) &&
      this.marketMachine.ifMarket4hModelLike([0, 1, 0]) &&
      this.marketMachine.ifMarket1hModelLike(['any', 0, [0, 1]]) &&
      !(this.marketFlagInfo.ifMarket15mAllGood || this.marketFlagInfo.ifMarket15mAllBad)
    ) {
      this.positionConfig = 0.35
      return
    }
    // 是不是不属于大行情阶段那就降低仓位
    // 一会儿亏3u，一会儿挣3u，就是没有趋势
    this.positionConfig = 0.75
  }
}
